package com.sabeot.library.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sabeot.library.hibernate.dao.UserDAO;
import com.sabeot.library.hibernate.dto.User;
import com.sabeot.library.service.UserService;

@Service("userService")
@Transactional(readOnly = true)
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDAO userDAO;
	
	public User findByUserId(Long id) {
		return userDAO.findById(id);
	}

	@Transactional(readOnly = false)
	public void saveUser(User user) {
		userDAO.saveUser(user);
	}
	
	@Transactional(readOnly = false)
	public void deleteUser(Long id) {
		User user = userDAO.findById(id);
		userDAO.delete(user);
	}

	public List<User> findUsers(String login) {
		return userDAO.findUsers(login);
	}

}
